#ifndef PROTOCOL_H_
#define PROTOCOL_H_

#include "base/base.h"
#include "include/rpc_def.h"

namespace rpc {
class Buffer;
class ProtoAttr;
class Processor;
class Connection;

class Protocol {
  public:
    virtual ~Protocol() {
    }

    virtual ProtoAttr* NewAttr() = 0;

    bool HandleRead(Connection* trans, Buffer* buf);

    void HandleWrite(Connection* trans, uint32 rpc_id, uint32 func_id,
                     const Message* msg);

  protected:
    explicit Protocol(Processor* p)
        : processor_(p) {
      CHECK_NOTNULL(p);
    }

  private:
    scoped_ptr<Processor> processor_;

    DISALLOW_COPY_AND_ASSIGN(Protocol);
};
}

#endif
